#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#pragma warning
/*int main()
{
	int i = 0;
	int j = 0;
	for (i = 1;i <= 9;i++)
	{
		for (j = 1;j <= i;j++)
		{
			printf("%d*%d=%d ",i,j,i*j);

		}
		printf("\n");
	}


	return 0;
}*/

/*int main()
{
	int arr[10] = { 0 };
	int i = 0;
	for (i = 0;i < 10;i++) {
		scanf("%d",&arr[i]);
	}
	int max=arr[0];
	int min = 0;
	for (i = 0;i < 10;i++) 
	{
		if (arr[i] >= max)
		{
			max = arr[i];
		}
		else if (arr[i] < max)
			min = 0;
		
    }
	printf("%d",max);
	return 0;
}*/
/*int main()
{
	int i = 0;
    double	sum = 0;
	for (i = 1;i <= 100;i++)
	{
		if (i % 2 == 1)
		{
			sum += 1.0 / i;
		}
		else
			sum -= 1.0 / i;

	}
	printf("%lf",sum);
	return 0;
}*/
/*int main()
{
	int i = 0;
	int nine = 0;
	for (i = 1;i <= 100;i++)
	{
		if ( i % 10 == 9||i/10==9)
			nine++;

	}
	printf("%d",nine);
	return 0;
}*/
/*int main()
{
	int i=0;
	for (i = 101;i <= 200;i += 2)
	{
		int ss = 1;
		int zs = 0;
		for (zs = 2;zs < i;zs++)
		{
			if (i % zs == 0)
			{
				ss = 0;	
			break;
			}
		}
		if (ss == 1)
			printf("%d ",i);


	}

	return 0;
}*/
/*int main()
{
	int n = 0;
	for (n = 1000;n <= 2000;n++)
	{
		if ((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0))
			printf("%d ",n);
	}
	return 0;
}*/
int main()
{
	int i = 0;
	int j = 0;
	scanf("%d %d",&i,&j);
	int k = (i > j ? j : i);
	while (1)
	{
		if (i % k == 0 && j % k == 0)
		{
			break;
		}
		k--;
	}
	printf("%d",k);


	return 0;
}



















